use "$Folder/Data_Civil_Servants_final.dta", clear
keep if sample==1

sum business_days if time==0 & treatment==0, detail
sum business_days if time==0 & treatment==1, detail
ttest business_days if time==0, by(treatment)
ranksum business_days if time==0, by(treatment)

sum business_days if time==1 & treatment==0, detail
sum business_days if time==1 & treatment==1, detail
ttest business_days if time==1, by(treatment)
ranksum business_days if time==1, by(treatment)

sum business_w5 if time==0 & treatment==0, detail
sum business_w5  if time==0 & treatment==1, detail
ttest business_w5  if time==0, by(treatment)
ranksum business_w5  if time==0, by(treatment)

sum business_w5  if time==1 & treatment==0, detail
sum business_w5  if time==1 & treatment==1, detail
ttest business_w5  if time==1, by(treatment)
ranksum business_w5  if time==1, by(treatment)

sum business_days_25  if time==0 & treatment==0, detail //.0335954
sum business_days_25  if time==1 & treatment==0, detail //.0543175

sum business_days_25  if time==0 & treatment==1, detail // .0351474
sum business_days_25  if time==1 & treatment==1, detail // .0924765

sum business_days_15  if time==0 & treatment==0, detail //.0564689
sum business_days_15  if time==1 & treatment==0, detail //.0396936

sum business_days_15  if time==0 & treatment==1, detail // .0379819
sum business_days_15  if time==1 & treatment==1, detail // .0462382


sum business_days if time==0 & treatment==0, detail
local q1 = r(p25)
local q2 = r(p50)
local q3 = r(p75)
local q4 = r(p95)
local Mean = r(mean)
twoway__histogram_gen business_days if time==0 & treatment==0, discrete percent gen(h x)
twoway (bar h x if x<66, color(white) lcolor(black))  || (pci 0 25 8.7 25 , lcolor(purple) lpattern(solid) lwidth(medium)) || (pci 0 15 8.7 15 , lcolor(green) lpattern(solid) lwidth(medium)) /// 
|| (pci 0 `q1' 7.6 `q1' 0 `q2' 7.6 `q2' 0 `q3' 7.6 `q3'  0 `q4' 7.6 `q4' , lcolor(red%50) lpattern(shortdash) lwidth(vthin)) /// 
|| (pci   0 `Mean' 7 `Mean' , lcolor(dknavy%50) lpattern(dash_dot) lwidth(vthin)),  text(8.2 `q1' "{bf:p25}", color(red%50) size(small))  text(8.2 13.2 "{bf:p50}", color(red%50) size(small)) ///
 text(8.2 23 "{bf:p75}", color(red%50) size(small)) text(9.5 25 "{bf:Second}", color(purple) size(small)) text(9 25 "{bf:deadline}", color(purple) size(small)) text(9.5 15 "{bf:First}", color(green) size(small)) text(9 15 "{bf:deadline}", color(green) size(small))  ///
 text(8.2 `q4' "{bf:p95}", color(red%50) size(small)) text(7.4 `Mean' "{bf:Mean}", color(dknavy%50) size(small))  ///
legend(off) ytitle("Percentage") name(g1, replace) ylabel(0(2)10, angle(horizontal)) title("Control group", color(black)) ///
graphregion(color(white)) plotregion(color(white)) xlabel(0(5)65)  xtitle("Business days") 
drop h x   
macro drop q1 q2 q3 q4


sum business_days if time==0 & treatment==1, detail
local q1 = r(p25)
local q2 = r(p50)
local q3 = r(p75)
local q4 = r(p95)
local Mean = r(mean)
twoway__histogram_gen business_days if time==0 & treatment==1, discrete percent gen(h x)
twoway (bar h x if x<66, color(white) lcolor(black))  || (pci 0 25 8.7 25, lcolor(purple) lpattern(solid) lwidth(medium)) || (pci 0 15 8.7 15 , lcolor(green) lpattern(solid) lwidth(medium)) /// 
|| (pci 0 `q1' 7.6 `q1' 0 `q2' 7.6 `q2' 0 `q3' 7.6 `q3'  0 `q4' 7.6 `q4' , lcolor(red%50) lpattern(shortdash) lwidth(vthin)) /// 
|| (pci   0 `Mean' 7 `Mean' , lcolor(dknavy%50) lpattern(dash_dot) lwidth(vthin)),  text(8.2 `q1' "{bf:p25}", color(red%50) size(small))  text(8.2 16.9 "{bf:p50}", color(red%50) size(small)) ///
 text(8.2 27 "{bf:p75}", color(red%50) size(small)) text(9.5 25 "{bf:Second}", color(purple) size(small)) text(9 25 "{bf:deadline}", color(purple) size(small)) text(9.5 15 "{bf:First}", color(green) size(small)) text(9 15 "{bf:deadline}", color(green) size(small))   ///
 text(8.2 `q4' "{bf:p95}", color(red%50) size(small)) text(7.4 `Mean' "{bf:Mean}", color(dknavy%50) size(small))  ///
legend(off) ytitle("") name(g2, replace) ylabel(0(2)10, angle(horizontal)) title("Treatment group", color(black)) ///
graphregion(color(white)) plotregion(color(white)) xlabel(0(5)65)  xtitle("Business days") 
drop h x   
macro drop q1 q2 q3 q4

graph combine g1 g2,  ycommon  graphregion(color(white)) cols(2) name(g7, replace) title("Panel A. Pre-intervention", color(black) size(medium))

sum business_days if time==1 & treatment==0, detail
local q1 = r(p25)
local q2 = r(p50)
local q3 = r(p75)
local q4 = r(p95)
local Mean = r(mean)
twoway__histogram_gen business_days if time==1 & treatment==0, discrete percent gen(h x)
twoway (bar h x if x<66, color(white) lcolor(black))  || (pci 0 25 8.7 25, lcolor(purple) lpattern(solid) lwidth(medium)) || (pci 0 15 8.7 15 , lcolor(green) lpattern(solid) lwidth(medium)) /// 
|| (pci 0 `q1' 7.6 `q1' 0 `q2' 7.6 `q2' 0 `q3' 8.7 `q3'  0 `q4' 7.6 `q4' , lcolor(red%50) lpattern(shortdash) lwidth(vthin)) /// 
|| (pci   0 `Mean' 7 `Mean' , lcolor(dknavy%50) lpattern(dash_dot) lwidth(vthin)),  text(8.2 `q1' "{bf:p25}", color(red%50) size(small))  text(8.2 `q2' "{bf:p50}", color(red%50) size(small)) ///
 text(9 22 "{bf:p75}", color(red%50) size(small)) text(9.5 28.8 "{bf:Second}", color(purple) size(small)) text(9 29.2 "{bf:deadline}", color(purple) size(small)) text(9.5 15 "{bf:First}", color(green) size(small)) text(9 15 "{bf:deadline}", color(green) size(small))   ///
 text(8.2 `q4' "{bf:p95}", color(red%50) size(small)) text(7.4 `Mean' "{bf:Mean}", color(dknavy%50) size(small))  ///
legend(off) ytitle("Percentage") name(g5, replace) ylabel(0(2)10, angle(horizontal)) title("Control group", color(black)) ///
graphregion(color(white)) plotregion(color(white)) xlabel(0(5)65)  xtitle("Business days") 
drop h x   
macro drop q1 q2 q3 

sum business_days if time==1 & treatment==1, detail
local q1 = r(p25)
local q2 = r(p50)
local q3 = r(p75)
local q4 = r(p95)
local Mean = r(mean)
twoway__histogram_gen business_days if time==1 & treatment==1, discrete percent gen(h x)
twoway (bar h x if x<66, color(white) lcolor(black))  || (pci 0 25 10 25, lcolor(purple) lpattern(solid) lwidth(medium)) || (pci 0 15 8.7 15 , lcolor(green) lpattern(solid) lwidth(medium)) /// 
|| (pci 0 `q1' 7.6 `q1' 0 `q2' 7.6 `q2' 0 `q3' 10 `q3'  0 `q4' 7.6 `q4' , lcolor(red%50) lpattern(shortdash) lwidth(vthin)) /// 
|| (pci   0 `Mean' 7 `Mean' , lcolor(dknavy%50) lpattern(dash_dot) lwidth(vthin)),  text(8.2 `q1' "{bf:p25}", color(red%50) size(small))  text(8.2 16.9 "{bf:p50}", color(red%50) size(small)) ///
 text(8.3 27.3 "{bf:p75}", color(red%50) size(small)) text(9.5 29 "{bf:Second}", color(purple) size(small)) text(9 29.4 "{bf:deadline}", color(purple) size(small)) text(9.5 15 "{bf:First}", color(green) size(small)) text(9 15 "{bf:deadline}", color(green) size(small))   ///
 text(8.2 `q4' "{bf:p95}", color(red%50) size(small)) text(7.4 `Mean' "{bf:Mean}", color(dknavy%50) size(small))  ///
legend(off) ytitle("") name(g6, replace) ylabel(0(2)10, angle(horizontal)) title("Treatment group", color(black)) ///
graphregion(color(white)) plotregion(color(white)) xlabel(0(5)65)  xtitle("Business days") 
drop h x   
macro drop q1 q2 q3 

graph combine g1 g2,  ycommon  graphregion(color(white)) cols(2) name(g7, replace) title("Panel A. Pre-intervention", color(black) size(medium))
graph combine g5 g6,  ycommon  graphregion(color(white)) cols(2) name(g9, replace) title("Panel B. Intervention", color(black) size(medium))
graph combine g7 g9,  ycommon  graphregion(color(white)) rows(3) title("", color(black))
graph export "$Figures/Figure_8.pdf", as(pdf) replace 

**FOOTNOTE 
tab business_days //This graph only shows closed requests. Overall, less than 4% of requests take more than 65 business days
